12 //assert(freopen("frieze.in", "r", stdin) != NULL);
14 while (cin
>> n
>> row
>> col
&& n
){
16 for (int i
=1; i
<=n
; ++i
) cin
>> f
[i
][1];
18 for (int j
=1; j
<=n
+1; ++j
) f
[1][j
] = f
[n
][j
] = 1;
20 for (int j
=2; j
<=n
+1; ++j
)
21 for (int i
=2; i
<n
; ++i
)
22 f
[i
][j
] = (f
[i
+1][j
-1]*f
[i
-1][j
]+1)/f
[i
][j
-1];
26 for (int i=1; i<=n; ++i){
27 for (int j=1; j<=n+1; ++j)
28 printf("%3d ", f[i][j]);
32 if (col
% (n
+1) == 0) col
= n
+1;
35 cout
<< f
[row
][col
] << endl
;